"""shareAPI2020TB URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.1/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.conf.urls import url
from django.contrib import admin
from django.http import HttpResponse
from django.urls import path
from django.conf import settings
from django.conf.urls.static import static
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.urls import path, include
from django.views.generic import TemplateView
from django.contrib.sitemaps.views import sitemap
from BaseWeb import views as BaseWebViews
from sitemaps import DetailPageSitemap, IndexPageSitemap
from shareAPI2020TB import views as shareViews
from django.urls import path, include, re_path
from django.views.static import serve
# 修改后台标题和关键信息
admin.site.site_header = "校园网系统控制中心"
admin.site.site_title = "逍遥令"
admin.site.index_title = "欢迎来到校园网控制台"
# 修改后台标题和关键信息--end
sitemaps = {
    'index': IndexPageSitemap,
    'detail': DetailPageSitemap,
}
##media配置——配合settings中的MEDIA_ROOT的配置，就可以在浏览器的地址栏访问media文件夹及里面的文件了

urlpatterns = [
        path('admin/', admin.site.urls),

        # path('tbitem/', include('tbitem.urls')),  # 淘宝模块自动发帖模块，基本废弃，源码仍旧很不错

        # '''基础网页部分,BaseWeb来负责框架搭建'''
        path('BaseWeb/', include('BaseWeb.urls')),  # 网站模块，展示网站内容
        path('index.html', BaseWebViews.WebIndex.as_view(), name='index'),
        path('index/<int:page>.html', BaseWebViews.WebIndex.as_view(), name='search'),  # 主页
        path('detail/<int:page>.html', BaseWebViews.Detail.as_view(), name='detail'),   #详情页
        path('login.html/', BaseWebViews.Login.as_view(), name='Login'),   # 登陆
        path('exit/', BaseWebViews.ExitUser.as_view(), name='exit'),  # 登出
        # path('vip/', BaseWebViews.Vip.as_view(), name='vip'),  # vip功能页面，所开发的功能模块汇总



        path('', BaseWebViews.WebIndex.as_view()),


        # path('addContent/', views.addContent.as_view(),name='addContent'), 文章发布内容

        # 7天落地页改变,7天以内的给普通页面，7天以上的给跳转页
        path('content/<int:type>/<int:id>/<int:time>', BaseWebViews.Redirect.as_view()),
        # path('testDDD/', views.testDDD.as_view()),  # 主页

        path('jd_root.txt', shareViews.gettxt),
        path('silian.txt', shareViews.gettxt),


        url(r'^sitemap\.xml$', sitemap, {'sitemaps': sitemaps, 'template_name': 'sitemap_baidu.xml'},name='django.contrib.sitemaps.views.sitemap'),
        url(r'^robots\.txt$', lambda r: HttpResponse('User-agent: *\nDisallow: /admin\nSitemap: http://www.tbzhu.com/sitemap.xml',content_type='text/plain')),


        # 静态文件配置
         url(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}, name='media'),
         url(r'^static/(?P<path>.*)$', serve,{'document_root': settings.STATIC_ROOT}, name='static'),
              ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)


urlpatterns += staticfiles_urlpatterns()